\(\int \frac {\tan ^2(e+f x)}{a+b \sec ^2(e+f x)} \, dx\) [345]

   Optimal result
   Rubi [A] (verified)
   Mathematica [C] (verified)
   Maple [A] (verified)
   Fricas [A] (verification not implemented)
   Sympy [F]
   Maxima [A] (verification not implemented)
   Giac [A] (verification not implemented)
   Mupad [B] (verification not implemented)

Optimal result

Integrand size = 23, antiderivative size = 46 \[ \int \frac {\tan ^2(e+f x)}{a+b \sec ^2(e+f x)} \, dx=-\frac {x}{a}+\frac {\sqrt {a+b} \arctan \left (\frac {\sqrt {b} \tan (e+f x)}{\sqrt {a+b}}\right )}{a \sqrt {b} f} \]

[Out]

-x/a+arctan(b^(1/2)*tan(f*x+e)/(a+b)^(1/2))*(a+b)^(1/2)/a/f/b^(1/2)

Rubi [A] (verified)

Time = 0.14 (sec) , antiderivative size = 46, normalized size of antiderivative = 1.00, number of steps used = 5, number of rules used = 5, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.217, Rules used = {4226, 2000, 492, 209, 211} \[ \int \frac {\tan ^2(e+f x)}{a+b \sec ^2(e+f x)} \, dx=\frac {\sqrt {a+b} \arctan \left (\frac {\sqrt {b} \tan (e+f x)}{\sqrt {a+b}}\right )}{a \sqrt {b} f}-\frac {x}{a} \]

[In]

Int[Tan[e + f*x]^2/(a + b*Sec[e + f*x]^2),x]

[Out]

-(x/a) + (Sqrt[a + b]*ArcTan[(Sqrt[b]*Tan[e + f*x])/Sqrt[a + b]])/(a*Sqrt[b]*f)

Rule 209

Int[((a_) + (b_.)*(x_)^2)^(-1), x_Symbol] :> Simp[(1/(Rt[a, 2]*Rt[b, 2]))*ArcTan[Rt[b, 2]*(x/Rt[a, 2])], x] /;
 FreeQ[{a, b}, x] && PosQ[a/b] && (GtQ[a, 0] || GtQ[b, 0])

Rule 211

Int[((a_) + (b_.)*(x_)^2)^(-1), x_Symbol] :> Simp[(Rt[a/b, 2]/a)*ArcTan[x/Rt[a/b, 2]], x] /; FreeQ[{a, b}, x]
&& PosQ[a/b]

Rule 492

Int[((e_.)*(x_))^(m_.)/(((a_) + (b_.)*(x_)^(n_))*((c_) + (d_.)*(x_)^(n_))), x_Symbol] :> Dist[(-a)*(e^n/(b*c -
 a*d)), Int[(e*x)^(m - n)/(a + b*x^n), x], x] + Dist[c*(e^n/(b*c - a*d)), Int[(e*x)^(m - n)/(c + d*x^n), x], x
] /; FreeQ[{a, b, c, d, e, m}, x] && NeQ[b*c - a*d, 0] && IGtQ[n, 0] && LeQ[n, m, 2*n - 1]

Rule 2000

Int[(u_)^(p_.)*(v_)^(q_.)*((e_.)*(x_))^(m_.), x_Symbol] :> Int[(e*x)^m*ExpandToSum[u, x]^p*ExpandToSum[v, x]^q
, x] /; FreeQ[{e, m, p, q}, x] && BinomialQ[{u, v}, x] && EqQ[BinomialDegree[u, x] - BinomialDegree[v, x], 0]
&&  !BinomialMatchQ[{u, v}, x]

Rule 4226

Int[((a_) + (b_.)*sec[(e_.) + (f_.)*(x_)]^(n_))^(p_.)*((d_.)*tan[(e_.) + (f_.)*(x_)])^(m_), x_Symbol] :> With[
{ff = FreeFactors[Tan[e + f*x], x]}, Dist[ff/f, Subst[Int[(d*ff*x)^m*((a + b*(1 + ff^2*x^2)^(n/2))^p/(1 + ff^2
*x^2)), x], x, Tan[e + f*x]/ff], x]] /; FreeQ[{a, b, d, e, f, m, p}, x] && IntegerQ[n/2] && (IntegerQ[m/2] ||
EqQ[n, 2])

Rubi steps \begin{align*} \text {integral}& = \frac {\text {Subst}\left (\int \frac {x^2}{\left (1+x^2\right ) \left (a+b \left (1+x^2\right )\right )} \, dx,x,\tan (e+f x)\right )}{f} \\ & = \frac {\text {Subst}\left (\int \frac {x^2}{\left (1+x^2\right ) \left (a+b+b x^2\right )} \, dx,x,\tan (e+f x)\right )}{f} \\ & = -\frac {\text {Subst}\left (\int \frac {1}{1+x^2} \, dx,x,\tan (e+f x)\right )}{a f}+\frac {(a+b) \text {Subst}\left (\int \frac {1}{a+b+b x^2} \, dx,x,\tan (e+f x)\right )}{a f} \\ & = -\frac {x}{a}+\frac {\sqrt {a+b} \arctan \left (\frac {\sqrt {b} \tan (e+f x)}{\sqrt {a+b}}\right )}{a \sqrt {b} f} \\ \end{align*}

Mathematica [C] (verified)

Result contains complex when optimal does not.

Time = 0.76 (sec) , antiderivative size = 184, normalized size of antiderivative = 4.00 \[ \int \frac {\tan ^2(e+f x)}{a+b \sec ^2(e+f x)} \, dx=-\frac {(a+2 b+a \cos (2 (e+f x))) \sec ^2(e+f x) \left (\sqrt {a+b} f x \sqrt {b (\cos (e)-i \sin (e))^4}+(a+b) \arctan \left (\frac {\sec (f x) (\cos (2 e)-i \sin (2 e)) (-((a+2 b) \sin (f x))+a \sin (2 e+f x))}{2 \sqrt {a+b} \sqrt {b (\cos (e)-i \sin (e))^4}}\right ) (\cos (2 e)-i \sin (2 e))\right )}{2 a \sqrt {a+b} f \left (a+b \sec ^2(e+f x)\right ) \sqrt {b (\cos (e)-i \sin (e))^4}} \]

[In]

Integrate[Tan[e + f*x]^2/(a + b*Sec[e + f*x]^2),x]

[Out]

-1/2*((a + 2*b + a*Cos[2*(e + f*x)])*Sec[e + f*x]^2*(Sqrt[a + b]*f*x*Sqrt[b*(Cos[e] - I*Sin[e])^4] + (a + b)*A
rcTan[(Sec[f*x]*(Cos[2*e] - I*Sin[2*e])*(-((a + 2*b)*Sin[f*x]) + a*Sin[2*e + f*x]))/(2*Sqrt[a + b]*Sqrt[b*(Cos
[e] - I*Sin[e])^4])]*(Cos[2*e] - I*Sin[2*e])))/(a*Sqrt[a + b]*f*(a + b*Sec[e + f*x]^2)*Sqrt[b*(Cos[e] - I*Sin[
e])^4])

Maple [A] (verified)

Time = 0.63 (sec) , antiderivative size = 48, normalized size of antiderivative = 1.04

method result size
derivativedivides \(\frac {-\frac {\arctan \left (\tan \left (f x +e \right )\right )}{a}+\frac {\left (a +b \right ) \arctan \left (\frac {b \tan \left (f x +e \right )}{\sqrt {\left (a +b \right ) b}}\right )}{a \sqrt {\left (a +b \right ) b}}}{f}\) \(48\)
default \(\frac {-\frac {\arctan \left (\tan \left (f x +e \right )\right )}{a}+\frac {\left (a +b \right ) \arctan \left (\frac {b \tan \left (f x +e \right )}{\sqrt {\left (a +b \right ) b}}\right )}{a \sqrt {\left (a +b \right ) b}}}{f}\) \(48\)
risch \(-\frac {x}{a}-\frac {\sqrt {-\left (a +b \right ) b}\, \ln \left ({\mathrm e}^{2 i \left (f x +e \right )}+\frac {2 i \sqrt {-\left (a +b \right ) b}+a +2 b}{a}\right )}{2 b f a}+\frac {\sqrt {-\left (a +b \right ) b}\, \ln \left ({\mathrm e}^{2 i \left (f x +e \right )}-\frac {2 i \sqrt {-\left (a +b \right ) b}-a -2 b}{a}\right )}{2 b f a}\) \(111\)

[In]

int(tan(f*x+e)^2/(a+b*sec(f*x+e)^2),x,method=_RETURNVERBOSE)

[Out]

1/f*(-1/a*arctan(tan(f*x+e))+(a+b)/a/((a+b)*b)^(1/2)*arctan(b*tan(f*x+e)/((a+b)*b)^(1/2)))

Fricas [A] (verification not implemented)

none

Time = 0.28 (sec) , antiderivative size = 226, normalized size of antiderivative = 4.91 \[ \int \frac {\tan ^2(e+f x)}{a+b \sec ^2(e+f x)} \, dx=\left [-\frac {4 \, f x - \sqrt {-\frac {a + b}{b}} \log \left (\frac {{\left (a^{2} + 8 \, a b + 8 \, b^{2}\right )} \cos \left (f x + e\right )^{4} - 2 \, {\left (3 \, a b + 4 \, b^{2}\right )} \cos \left (f x + e\right )^{2} - 4 \, {\left ({\left (a b + 2 \, b^{2}\right )} \cos \left (f x + e\right )^{3} - b^{2} \cos \left (f x + e\right )\right )} \sqrt {-\frac {a + b}{b}} \sin \left (f x + e\right ) + b^{2}}{a^{2} \cos \left (f x + e\right )^{4} + 2 \, a b \cos \left (f x + e\right )^{2} + b^{2}}\right )}{4 \, a f}, -\frac {2 \, f x + \sqrt {\frac {a + b}{b}} \arctan \left (\frac {{\left ({\left (a + 2 \, b\right )} \cos \left (f x + e\right )^{2} - b\right )} \sqrt {\frac {a + b}{b}}}{2 \, {\left (a + b\right )} \cos \left (f x + e\right ) \sin \left (f x + e\right )}\right )}{2 \, a f}\right ] \]

[In]

integrate(tan(f*x+e)^2/(a+b*sec(f*x+e)^2),x, algorithm="fricas")

[Out]

[-1/4*(4*f*x - sqrt(-(a + b)/b)*log(((a^2 + 8*a*b + 8*b^2)*cos(f*x + e)^4 - 2*(3*a*b + 4*b^2)*cos(f*x + e)^2 -
 4*((a*b + 2*b^2)*cos(f*x + e)^3 - b^2*cos(f*x + e))*sqrt(-(a + b)/b)*sin(f*x + e) + b^2)/(a^2*cos(f*x + e)^4
+ 2*a*b*cos(f*x + e)^2 + b^2)))/(a*f), -1/2*(2*f*x + sqrt((a + b)/b)*arctan(1/2*((a + 2*b)*cos(f*x + e)^2 - b)
*sqrt((a + b)/b)/((a + b)*cos(f*x + e)*sin(f*x + e))))/(a*f)]

Sympy [F]

\[ \int \frac {\tan ^2(e+f x)}{a+b \sec ^2(e+f x)} \, dx=\int \frac {\tan ^{2}{\left (e + f x \right )}}{a + b \sec ^{2}{\left (e + f x \right )}}\, dx \]

[In]

integrate(tan(f*x+e)**2/(a+b*sec(f*x+e)**2),x)

[Out]

Integral(tan(e + f*x)**2/(a + b*sec(e + f*x)**2), x)

Maxima [A] (verification not implemented)

none

Time = 0.27 (sec) , antiderivative size = 45, normalized size of antiderivative = 0.98 \[ \int \frac {\tan ^2(e+f x)}{a+b \sec ^2(e+f x)} \, dx=\frac {\frac {{\left (a + b\right )} \arctan \left (\frac {b \tan \left (f x + e\right )}{\sqrt {{\left (a + b\right )} b}}\right )}{\sqrt {{\left (a + b\right )} b} a} - \frac {f x + e}{a}}{f} \]

[In]

integrate(tan(f*x+e)^2/(a+b*sec(f*x+e)^2),x, algorithm="maxima")

[Out]

((a + b)*arctan(b*tan(f*x + e)/sqrt((a + b)*b))/(sqrt((a + b)*b)*a) - (f*x + e)/a)/f

Giac [A] (verification not implemented)

none

Time = 0.45 (sec) , antiderivative size = 66, normalized size of antiderivative = 1.43 \[ \int \frac {\tan ^2(e+f x)}{a+b \sec ^2(e+f x)} \, dx=\frac {\frac {{\left (\pi \left \lfloor \frac {f x + e}{\pi } + \frac {1}{2} \right \rfloor \mathrm {sgn}\left (b\right ) + \arctan \left (\frac {b \tan \left (f x + e\right )}{\sqrt {a b + b^{2}}}\right )\right )} {\left (a + b\right )}}{\sqrt {a b + b^{2}} a} - \frac {f x + e}{a}}{f} \]

[In]

integrate(tan(f*x+e)^2/(a+b*sec(f*x+e)^2),x, algorithm="giac")

[Out]

((pi*floor((f*x + e)/pi + 1/2)*sgn(b) + arctan(b*tan(f*x + e)/sqrt(a*b + b^2)))*(a + b)/(sqrt(a*b + b^2)*a) -
(f*x + e)/a)/f

Mupad [B] (verification not implemented)

Time = 19.66 (sec) , antiderivative size = 126, normalized size of antiderivative = 2.74 \[ \int \frac {\tan ^2(e+f x)}{a+b \sec ^2(e+f x)} \, dx=-\frac {\mathrm {atan}\left (\frac {2\,a\,b^2\,\mathrm {tan}\left (e+f\,x\right )}{2\,a^2\,b+2\,a\,b^2}+\frac {2\,a^2\,b\,\mathrm {tan}\left (e+f\,x\right )}{2\,a^2\,b+2\,a\,b^2}\right )}{a\,f}-\frac {\mathrm {atanh}\left (\frac {2\,a\,b^2\,\mathrm {tan}\left (e+f\,x\right )\,\sqrt {-b^2-a\,b}}{2\,a^2\,b^2+2\,a\,b^3}\right )\,\sqrt {-b\,\left (a+b\right )}}{a\,b\,f} \]

[In]

int(tan(e + f*x)^2/(a + b/cos(e + f*x)^2),x)

[Out]

- atan((2*a*b^2*tan(e + f*x))/(2*a*b^2 + 2*a^2*b) + (2*a^2*b*tan(e + f*x))/(2*a*b^2 + 2*a^2*b))/(a*f) - (atanh
((2*a*b^2*tan(e + f*x)*(- a*b - b^2)^(1/2))/(2*a*b^3 + 2*a^2*b^2))*(-b*(a + b))^(1/2))/(a*b*f)